 {layout name="common/layout" /}
 
 <style>
	.setting_all{
		font-size: 15px;
		height: 35px;
		width: 100px;
		text-align: center;
		line-height: 30px !important;
		color: #fff;
		border-radius: 3px;
		cursor: pointer;
		background-color: #2196f3;
		margin-left: 5px;
	 }
 </style>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>


<div class="Hui-article-box">
	<div class="Hui-article" style="top:0px;">
		<!-- 商品列表主体页面 -->
			<h3 class="showlist_title">所有商品</h3>

			<div class="showlist_form"> 
				<form action="{:url('goods/showlist')}" method="get" style="border:0;"> 
					<?php $keyword = input('param.keyword'); ?>
					<span >商品名称</span><input type="text" value="{$keyword}" class="input-text" style="width:250px" placeholder="输入商品关键词" id="" name="keyword">
					
					<!-- 时间选择器 -->
					<div class="showlist_timeselect" >
					<?php 
						$begintime = input('param.begintime');
						$endtime = input('param.endtime');
						$type = input('param.type');
					?>
					录入时间
					<input id="d11" value="{$begintime}"  name="begintime" class="input-text radius size-M" type="text" onClick="WdatePicker()"/>
					<b style="color: #000;font-weight: normal;margin-left: 5px;">至</b>
					<input id="d11" value="{$endtime}" name="endtime"  class="input-text radius size-M input-boxs" type="text" onClick="WdatePicker()"/>
				</div>
					<button type="submit" class="btn btn-success radius" id="btn_sub" name=""> 搜索</button>
					<a class="btn setting_all" href="/merchant/goodsattr/show">批量设置</a>
					<input id="type" value="{$type}" style="width:140px;" name="type"  type="hidden"/>
				</form>
			</div>
			<div  >
				
				<div id="tab_demo" class="HuiTab">
				  <div class="tabBar clearfix showlist_tabBar"><span >全部商品</span><span>已上架商品</span><span>保存的商品</span><span>已下架的商品</span></div>
				  <?php if ($type == 0) { ?>
				  <div class="tabCon">
					<table class="table table-border table-bg  table-bordered" >
 						<tr class="text-c first-tr">
 							<td>主图</td>
 							<td>商品名称</td>
 							<td>主营类目</td>
 							<td>时间</td>
 							<td>操作</td>
  						</tr>
  						{foreach($data as $k => $v)}
  						<tr style="height: 120px;" class="text-c">
 							<td><img src="GOODS_MAIN_PATH/{$v['goods_main_pic']}" alt="" ></td>
 							<td>{$v['goods_name']}</td>
 							<td>{$v['goods_category_name']}</td>
 							<td>{$v['goods_create_time']}</td>
 							<td>
							<a href="{:url('goods/goods_edit', ['goods_id'=>$v['goods_id']])}" class="aa">修改</a>
							<?php
							if($v["goods_is_delete"]==0){
								if($v["goods_shelf_state"]==3 || $v["goods_shelf_state"]==1)
								{
								echo '<a href="javascript:void(0);" onclick="puton('.$v['goods_id'].');" class="aa">上架</a>';
								}else
								{
								echo '<a href="javascript:void(0);" onclick="putdown('.$v['goods_id'].');" class="aa">下架</a>';
								}
							}
							?>
							<a href="javascript:void(0);" onclick="del({$v['goods_id']});" class="aa">删除</a></td>
  						</tr>
  						{/foreach}
					</table>
				<div class="cl">
						 <!--<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesizes?$pagesizes : 5} ，共 {$data->total()} 条</div>-->
					    {$data->render()} 
				</div>
				<?php } elseif ($type == 1) { ?>
				<div class="tabCon"></div>
				<div class="tabCon">
					<table class="table table-border table-bg  table-bordered" >
 						<tr class="text-c first-tr">
 							<td>主图</td>
 							<td>商品名称</td>
 							<td>主营类目</td>
 							<td>上架时间</td>
 							<td>操作</td>
  						</tr>
  						{foreach($data as $k1 => $v1)}
						
  						<tr style="height: 90px;" class="text-c">
 							<td><img src="GOODS_MAIN_PATH/{$v1['goods_main_pic']}" alt="" ></td>
 							<td>{$v1['goods_name']}</td>
 							<td>{$v1['goods_category_name']}</td>
 							<td>{$v1['goods_create_time']}</td>
 							<td>
							<a href="{:url('goods/goods_edit', ['goods_id'=>$v1['goods_id']])}" class="aa">修改</a>
						     <a href="javascript:void(0);" onclick="putdown({$v1['goods_id']});" class="aa">下架</a>
							<a href="javascript:void(0);" onclick="del({$v1['goods_id']});" class="aa">删除</a>
							</td>
  						</tr>
  						{/foreach}
					</table>
				   <div class="cl">
						  <!--<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesizes?$pagesizes : 5} ，共 {$data->total()} 条</div>-->
					    {$data->render()} 
					</div>
				</div>
				<?php } else if ($type == 2) {?>
				<div class="tabCon"></div>
				<div class="tabCon"></div>
				<div class="tabCon">
					<table class="table table-border table-bg  table-bordered" >
 						<tr class="text-c first-tr">
 							<td>主图</td>
 							<td>商品名称</td>
 							<td>主营类目</td>
 							<td>保存时间</td>
 							<td>操作</td>
  						</tr>
  						{foreach($data as $k2 => $v2)}
  						<tr style="height: 120px;" class="text-c">
 							<td><img src="GOODS_MAIN_PATH/{$v2['goods_main_pic']}" alt="" >
 							<td>{$v2['goods_name']}</td>
 							<td>{$v2['goods_category_name']}</td>
 							<td>{$v2['goods_create_time']}</td>
 							<td>
							<a href="{:url('goods/goods_edit', ['goods_id'=>$v2['goods_id']])}" class="aa">修改</a>
							<a href="javascript:void(0);" onclick="puton({$v2['goods_id']});" class="aa">上架</a>
							<a href="javascript:void(0);" onclick="del({$v2['goods_id']});" class="aa">删除</a>
							</td>
  						</tr>
  						{/foreach}
					</table>
				    <div class="cl">
					<!--<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesizes?$pagesizes : 5} ，共 {$data->total()} 条</div>-->
					    {$data->render()}
					</div>
				</div>
				  <?php } else if ($type == 3) {?>
				<div class="tabCon"></div>
				<div class="tabCon"></div>
				<div class="tabCon"></div>
				<div class="tabCon">
					<table class="table table-border table-bg  table-bordered" >
 						<tr class="text-c first-tr">
 							<td>主图</td>
 							<td>商品名称</td>
 							<td>主营类目</td>
 							<td>下架时间</td>
 							<td>操作</td>
  						</tr>
  						{foreach($data as $k3 => $v3)}
  						<tr style="height: 120px;" class="text-c">
 							<td><img src="GOODS_MAIN_PATH/{$v3['goods_main_pic']}" alt="" ></td>
 							<td>{$v3['goods_name']}</td>
 							<td>{$v3['goods_category_name']}</td>
 							<td>{$v3['goods_create_time']}</td>
 							<td>
							<a href="{:url('goods/goods_edit', ['goods_id'=>$v3['goods_id']])}" class="aa">修改</a>
							<a href="javascript:void(0);" onclick="puton({$v3['goods_id']});" class="aa">上架</a>
							<a href="javascript:void(0);" onclick="del({$v3['goods_id']});" class="aa">删除</a>
							</td>
  						</tr>
  						{/foreach}
					</table>
				    <div class="cl">
						<!--<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesizes?$pagesizes : 5} ，共 {$data->total()} 条</div>-->
					    {$data->render()}
					</div>
				</div>
				<?php } ?>
			</div>
		</div>
	</div>
</div>
 
<script>
	$(function()
	{
	    
	$.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","current","click","{$type}")
	
	}
	
	);
	var GG = 
	{
        "kk":function(mm)
		{
           var ym=mm;
        }
    }
	$(".paginate").initPage(71,1,GG.kk);
	 
	 
	 
	
	 $(function()
	 {   
       // 为span元素绑定click事件  
     $('#tab_demo .tabBar span').bind("click",function(event)
	 { 
		
      // $('#type').val(1); 
	   if($(this).html()=="全部商品")
	   {
	   $('#type').val(0); 
	    $('#type1').val(0);
	 
	   } 
	   if($(this).html()=="已上架商品")
	   {
	   $('#type').val(1); 
	   $('#type1').val(1);
	 
	   } 
	   if($(this).html()=="保存的商品")
	   {
	    $('#type').val(2); 
		$('#type1').val(2);
	   } 
	    if($(this).html()=="已下架的商品")
	   {
	    $('#type').val(3); 
		$('#type1').val(3);
	   } 
	     $("#btn_sub").click();
    });   
     
})   
	
	 
	
	
function del(id)
	{
		layer.msg('你确定要删除吗？', {
		  time: 0, 
		  btn: ['确定', '取消'],
		  area: ['250px', '120px'],
		  btnAlign: 'c',
		  yes: function(index){
	    	layer.close(index);
	    	$.ajax({
			type : 'get',
			url : "<?php echo url('goods/delete', '', false); ?>/goods_id/" + id,
			dataType : 'json',
			success : function(data){
			if(data.status == 1)
			{
				layer.msg(data.msg, 
				{
				  offset: 't',
				  anim: 5,
				  success : function()
				  {
				  	location.reload();
				  }
				});
			}
				
			}
		});
		  }
		});		
		
	}
	function putdown(id)
	{
        $.ajax({
            type : 'get',
            url : "<?php echo url('goods/goods_putdown', '', false); ?>/goods_id/" + id,
            dataType : 'json',
            success : function(data){
                if(data.status == 1)
                {
                    layer.msg(data.msg, {
                        offset: 't',
                        anim: 5,
                        success : function(){
                            location.reload();
                        }
                    });
                }

            }
        });
//		layer.msg('你确定要下架吗？', {
//		  time: 0,
//		  btn: ['确定', '取消'],
//		  area: ['250px', '120px'],
//		  btnAlign: 'c',
//		  yes: function(index){
//	    	layer.close(index);
//		  }
//		});
	}
	function puton(id)
	{
        $.ajax({
            type : 'get',
            url : "<?php echo url('goods/goods_puton', '', false); ?>/goods_id/" + id,
            dataType : 'json',
            success : function(data){
                if(data.status == 1)
                {
                    layer.msg(data.msg, {
                        offset: 't',
                        anim: 5,
                        success : function(){
                            location.reload();
                        }
                    });
                }

            }
        });
//		layer.msg('你确定要上架吗？', {
//		  time: 0,
//		  btn: ['确定', '取消'],
//		  area: ['250px', '120px'],
//		  btnAlign: 'c',
//		  yes: function(index){
//	    	layer.close(index);
//		  }
//		});
	}
</script>
 